package com.college.dao;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.college.bean.User;
import com.college.db.connection.DBConnecton;

public class RegistrationDao {

	private static final long serialVersionUID = 1L;
	
	public boolean registrationDao(User user) throws SQLException, ClassNotFoundException, IOException{
		
		Connection con;
		Statement stmt;
		ResultSet rs;
		PrintWriter out;
		DBConnecton dbConnecton = new DBConnecton();
		
		con = dbConnecton.getDBConnection();
		
		stmt=con.createStatement();
		
		CallableStatement userQuery = con.prepareCall("{call userregistration(?,?,?,?,?,)}"); 
		userQuery.setString(1, user.getUserName()); 
		userQuery.setString(2, user.getPassword()); 
		userQuery.setString(3, user.getAddress()); 
		userQuery.setString(4, user.getDob()); 
		userQuery.setString(5, user.getContactNo()); 

		
		rs = userQuery.executeQuery();
		
		if(rs.next()){
			
			return true;
		}

		return false;
	}
}
